
<extend name="Application/Admin/View/head.html" />
		<block name="conten">
			<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
							<div class="panel panel-default bk-bg-white">
								<div class="panel-heading bk-bg-white">
									<h6><i class="fa fa-table red"></i><span class="break"></span>商品分类列表</h6>							
									
								</div>
								<div class="panel-body">
									<div class="row">
										
											
											<a href="{:U('GoodsCategory/add')}">	<button class="btn btn-info" id="addToTable">商品分类添加<i class="fa fa-plus"></i></button></a>
											</div>
										</div>
									</div>
									<div id="datatable-editable_wrapper" class="dataTables_wrapper no-footer"></div></div><div class="table-responsive"><table id="datatable-editable" class="table table-bordered table-striped mb-none dataTable no-footer" role="grid" aria-describedby="datatable-editable_info">
										<thead>


											<tr role="row"><th class="sorting_asc" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 265px;" aria-sort="ascending" aria-label="Template: activate to sort column ascending"></th>
											<th class="sorting" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 415px;" aria-label="Browser: activate to sort column ascending">ID</th>
											<th class="sorting" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 415px;" aria-label="Browser: activate to sort column ascending">商品分类名</th>

											<th class="sorting" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 415px;" aria-label="Browser: activate to sort column ascending">等级</th>

											<th class="sorting" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 534px;" aria-label="Platform(s): activate to sort column ascending">是否显示</th>

											<th class="sorting" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 534px;" aria-label="Platform(s): activate to sort column ascending">PID</th>

											<th class="sorting" tabindex="0" aria-controls="datatable-editable" rowspan="1" colspan="1" style="width: 534px;" aria-label="Platform(s): activate to sort column ascending">操作</th>

										</thead>
										<tbody>
			
										<foreach name="lists" item="v" >	
										<tr class="gradeA odd" role="row"  level="{$v['level']}">

										
												<td><button off="1" value="{$v.id}" class="btn sorting_1 btn-success glyphicon glyphicon-plus" type="button"></button></td>
												<td>{$v['id']}</td>
												<td>{$v['c_name']}</td>
												<td>1</td>
												<td>{$v['is_show']==1?'是':'否'}</td><!-- 是否显示 -->
	 
												
												<td>{$v['pid']}</td>
												<td class="actions">
													<a class="hidden on-editing save-row" href="#"><i class="fa fa-save"></i></a>
													<a class="hidden on-editing cancel-row" href="#"><i class="fa fa-times"></i></a>
													<a class="on-default edit-row" href="#"><i class="fa fa-pencil"></i></a>
													<a class="on-default remove-row" href="#"><i class="fa fa-trash-o"></i></a>
												</td>
											</tr></foreach>
										</tbody>
									</table></div>
									
									{$page}
								</div>
							</div>
						</div>
						
						<script src="__ADMIN__/assets/vendor/js/jquery.min.js"></script>
		<script src="__ADMIN__/assets/vendor/js/jquery-2.1.1.min.js"></script>
		<script src="__ADMIN__/assets/vendor/js/jquery-migrate-1.2.1.min.js"></script>
		<script src="__ADMIN__/assets/vendor/bootstrap/js/bootstrap.min.js"></script>
		<script src="__ADMIN__/assets/vendor/skycons/js/skycons.js"></script>	
		<script src="__ADMIN__/assets/vendor/js/pace.min.js"></script>
		
		<!-- Plugins JS-->
		<script src="__ADMIN__/assets/plugins/jquery-ui/js/jquery-ui-1.10.4.min.js"></script>
		<script src="__ADMIN__/assets/plugins/touchpunch/js/jquery.ui.touch-punch.min.js"></script>		
		<script src="__ADMIN__/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
		<script src="__ADMIN__/assets/plugins/bootstrap-timepicker/js/bootstrap-timepicker.js"></script>
		<script src="__ADMIN__/assets/plugins/bootstrap-colorpicker/js/bootstrap-colorpicker.js"></script>
		<script src="__ADMIN__/assets/plugins/bootstrap-tagsinput/js/bootstrap-tagsinput.js"></script>
		<script src="__ADMIN__/assets/plugins/maskedinput/js/jquery.maskedinput.js"></script>
		<script src="__ADMIN__/assets/plugins/sparkline/js/jquery.sparkline.min.js"></script>
		
		<!-- Theme JS -->		
		<script src="__ADMIN__/assets/js/jquery.mmenu.min.js"></script>
		<script src="__ADMIN__/assets/js/core.min.js"></script>
		
		<!-- Pages JS -->
		<script src="__ADMIN__/assets/js/pages/form-elements.js"></script>
		<script type="text/javascript">
			$(function(){
				$(".sorting_1").live('click',function(){
					var id = $(this).val();
					var child = $(this);
					var off = $(this).attr('off');
					if(off==1){
							$(this).removeClass('glyphicon-plus');
							$(this).addClass('glyphicon-minus');
				      		$(this).attr('off',0); //改变状态

					$.ajax({
						type:"POST",
						url:"{:U('Ajax/lists')}",
						data:{'id':id},
						dataType:'json',
						success: function(e){
						var html = '';
						var len	= e.length-1;
						if (off==0) {
							
							var level = child.parent().parent().attr('level');
							child.parent().parent().nextUntil('tr[level='+level+']').remove(); 
						}else{
				     	if (e!='') {
				      	for (i in e){      		
				      		html+='<tr  class="gradeA odd" role="row" level="'+e[i].level+'">';
				     		html+='<td ><button value='+e[i].id+' off="1" style="margin-left:35px" class="btn sorting_1 btn-success glyphicon glyphicon-plus" type="button"></button></td>';
				      		html+='<td>'+e[i].id+'</td>';
				      		html+='<td>'+e[i].c_name+'</td>';
				      		html+='<td>'+e[i].level+'</td>';
				      		var is_show = e[i].is_show==1?'是':'否';
				      		html+='<td>'+is_show+'</td>';
				      		html+='<td>'+e[i].pid+'</td>';
				      		html+='<td></td>';
							html+='</tr>';
							if (i==len) {
								
								html+='<tr level="'+e[i].level+'" style="display:none;"></tr>';
							}
							
				      	}
				      	child.parent().parent().after(html);	
				     }
				      }
				      	
						

						}
					})
				      }else{
				      		$(this).removeClass('glyphicon-minus');
							$(this).addClass('glyphicon-plus');
				      		$(this).attr('off',1);//改变状态

				      	var level = child.parent().parent().attr('level');
							child.parent().parent().nextUntil('tr[level="'+level+'"]').remove(); 
				      }

					
					
					
					
				})
					
				
			})
					</script>
						</block>